package com.wpf.springbootflux.utils;

import com.wpf.springbootflux.bean.Person;
import com.wpf.springbootflux.exception.ValidException;

import java.util.stream.Stream;

public class ValidUtil {

    private static final String[] INVALID_NAMES = { "admin", "wangpengfei" };

    public static void validVale(Person person) {

        Stream.of(INVALID_NAMES).
                filter(name -> name.equalsIgnoreCase(person.getName()))
                .findAny()
                .ifPresent(name->{
                    throw new ValidException("name",person.getName());
                });
    }

}
